﻿<%@ page contentType="text/html; charset=utf-8"%>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
	<title>Web报表(B/S报表)演示, 打印支票，向报表传递参数数据</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<script src="../CreateControl.js" type="text/javascript"></script>
	<script type="text/javascript">
        //在网页初始加载时设置参数并启动报表的运行显示
        function window_onload() {
            var BeginDate = '<%=request.getParameter("BeginDate")%>',
                EndDate = '<%=request.getParameter("EndDate")%>',
                CategoryID = '<%=request.getParameter("CategoryID")%>',
                ProductID = '<%=request.getParameter("ProductID")%>'
                City = '<%=request.getParameter("City")%>',
                CompanyName = '<%=request.getParameter("CompanyName")%>';

			if (CategoryID == "null") {
				CategoryID = "";
			}
			if (ProductID == "null") {
				ProductID = "";
			}
			if (City == "null") {
				City = "";
			}
			if (CompanyName == "null") {
				CompanyName = "";
			}
            if (BeginDate == "null") {
                BeginDate  = "1997-1-1";
            }
            if (EndDate == "null") {
                EndDate  = "1997-12-31";
            }

            document.getElementById("txtBeginDate").value = BeginDate;
            document.getElementById("txtEndDate").value = EndDate;
            document.getElementById("txtCategoryID").value = CategoryID;
            document.getElementById("txtProductID").value = ProductID;
            document.getElementById("txtCity").value = City;
            document.getElementById("txtCompanyName").value = CompanyName;

	        btnRefresh_onclick();
        }

        //打印预览报表
        function btnPreview_onclick() {
            ReportViewer.Report.PrintPreview(true);
        }

        //根据数据过滤参数重新显示报表
        function btnRefresh_onclick() {
            var BeginDate = document.getElementById("txtBeginDate").value,
                EndDate = document.getElementById("txtEndDate").value,
                CategoryID = document.getElementById("txtCategoryID").value,
                ProductID = document.getElementById("txtProductID").value,
                City = document.getElementById("txtCity").value,
                CompanyName = document.getElementById("txtCompanyName").value,
                dataURL = "../../data/DataCenter.jsp?data=FilterSaleDetail",
                params;
    
        
            subTitle = "日期范围: " + BeginDate + "至" + EndDate;
            params = "&BeginDate=" + BeginDate + "&EndDate=" + EndDate;
            if (CategoryID) {
                subTitle += " 产品类别: " + CategoryID;
                params += "&CategoryID=" + CategoryID;
            }
            if (ProductID) {
                subTitle += " 产品编号: " + ProductID;
                params += "&ProductID=" + ProductID;
            }
            if (City) {
                subTitle += " 客户城市: " + City;
                params += "&City=" + City;
            }
            if (CompanyName) {
                subTitle += " 公司名称: " + CompanyName;
                params += "&CompanyName=" + CompanyName;
            }
            dataURL += params;
            
            ReportViewer.Stop();
            
            //更新查询参数更新报表付标题，设置对应静态框的“Text”属性
            ReportViewer.Report.ControlByName("SubTitle").AsStaticBox.Text = subTitle; //"日期范围: " + BeginDate + "至" + EndDate + " 产品编号: " + ProductID;
            
            ReportViewer.DataURL = encodeURI(dataURL);
            
            ReportViewer.Start();
        }
	</script>
</head>
<body style="margin:0; background-color: #f0ffff;"  onload="window_onload()">
	<table border="0" width="100%" style="height: 100%;">
		<tr style="height: 10px">
			<td>
                <span>开始日期：</span>
                <input id="txtBeginDate" type="text" value="1997-1-1" maxlength="20" style="width: 84px" />
                <span>结束日期：</span>
                <input id="txtEndDate" type="text" value="1997-12-31" maxlength="20" style="width: 80px" />

                <span>产品类别ID:</span>
                <input id="txtCategoryID" type="text" size="3" value="" />
                <span>产品ID:</span>
                <input id="txtProductID" type="text" size="3" value="" />

                <span>客户城市:</span>
                <input id="txtCity" type="text" size="8" value="" />
                <span>公司名称:</span>
                <input id="txtCompanyName" type="text" size="16" value="" />

                <input id="btnRefresh" onclick="return btnRefresh_onclick()" type="button" value="更新显示"/>
            </td>
		    <td>
                <input id="btnPreview" onclick="return btnPreview_onclick()" type="button" value="打印预览"/>
            </td>
		</tr>
        <tr style="height: 100%">
            <td colspan="2" height="100%">
                <script type="text/javascript"> 
                    CreateDisplayViewerEx("100%", "100%", "../../grf/SummaryToDetail/Detail.grf", "", false, "<param name=BorderStyle value=1>");
                </script>
            </td>
        </tr>
	</table>
</body>
</html>